USB Human Interface Device Class
   HOME

TheInfoList



OR:

In
computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, the USB human interface device class (USB HID class) is a part of the USB specification for
computer peripheral A peripheral or peripheral device is an auxiliary device used to put information into and get information out of a computer. The term ''peripheral device'' refers to all hardware components that are attached to a computer and are controlled by th ...
s: it specifies a device class (a type of
computer hardware Computer hardware includes the physical parts of a computer, such as the case, central processing unit (CPU), random access memory (RAM), monitor, mouse, keyboard, computer data storage, graphics card, sound card, speakers and motherboard. ...
) for human interface devices such as keyboards,
mice A mouse ( : mice) is a small rodent. Characteristically, mice are known to have a pointed snout, small rounded ears, a body-length scaly tail, and a high breeding rate. The best known mouse species is the common house mouse (''Mus musculus'' ...
,
game controller A game controller, gaming controller, or simply controller, is an input device used with video games or entertainment systems to provide input to a video game, typically to control an object or character in the game. Before the seventh generatio ...
s and alphanumeric
display device A display device is an output device for presentation of information in visual or tactile form (the latter used for example in tactile electronic displays for blind people). When the input information that is supplied has an electrical signal the ...
s. The USB HID class is defined in a number of documents provided by the USB Implementers Forum's Device Working Group. The primary document used to describe the USB HID class is the Device Class Definition for HID 1.11.


Devices

The USB HID class describes devices used with nearly every modern computer. Many predefined functions exist in the USB HID class. These functions allow hardware manufacturers to design a product to USB HID class specifications and expect it to work with any software that also meets these specifications. The same HID protocol is used unmodified in
Bluetooth Bluetooth is a short-range wireless technology standard that is used for exchanging data between fixed and mobile devices over short distances and building personal area networks (PANs). In the most widely used mode, transmission power is limi ...
human interface devices. The Bluetooth profile specification only points readers to the USB HID documentation. In this sense those devices also belong to the USB HID class.


Keyboards

Keyboards are a common kind of USB HID class device. The USB HID class keyboard is normally designed with an IN endpoint that communicates keystrokes to the computer and an OUT endpoint that communicates the status of the keyboard's LEDs from the computer to the keyboard. The
PC 97 The PC System Design Guide (also known as the PC-97, PC-98, PC-99, or PC 2001 specification) is a series of hardware design requirements and recommendations for IBM PC compatible personal computers, compiled by Microsoft and Intel Corporation durin ...
standard requires that a computer's
BIOS In computing, BIOS (, ; Basic Input/Output System, also known as the System BIOS, ROM BIOS, BIOS ROM or PC BIOS) is firmware used to provide runtime services for operating systems and programs and to perform hardware initialization during the b ...
must detect and work with USB HID class keyboards that are designed to be used during the boot process. Some keyboards implement the ''USB Boot Keyboard'' profile specified in the USB Device Class Definition for Human Interface Devices (HID) v1.11 and are explicitly configured to use the boot protocol. These are limited to 6-key rollover (6KRO) and will interrupt the CPU every time the keyboard is polled (even if there is no state change) unless the USB controller overrides this behavior. This profile is intended to allow the BIOS to handle a USB keyboard in the absence of a USB-aware operating system. The recommended profile for keyboards that are not in boot mode in this specification limits keyboards to 6KRO and causes them to respond to an interrupt with a status report at least every half second (again, even if there is no state change) in order to implement typematic (repeating the scancode when the key is pressed long enough) unless the USB controller is programmed to tell the keyboard not to do this. However, keyboards in non-boot mode are free to implement an alternative HID profile. The above-mentioned behavior is in contrast to the
PS/2 The Personal System/2 or PS/2 is IBM's second generation of personal computers. Released in 1987, it officially replaced the IBM PC, XT, AT, and PC Convertible in IBM's lineup. Many of the PS/2's innovations, such as the 16550 UART (serial p ...
(not to be confused with PlayStation 2) interface, which supports ''n''-key rollover (NKRO) for keyboards capable of supporting it.


Mice

Computer mice are another common USB HID class device. USB HID mice can range from single-button simple devices to multi-button compound devices. Most modern operating systems ship with drivers for standard HID mouse designs (the most common modern mouse design has two dedicated buttons and a mouse wheel that doubles as the third button); mice with extended functionality require custom drivers from the manufacturer. USB mice have lower latencies than PS/2 mice because standard USB mice are often polled at a default rate of 125 Hz while standard PS/2 mice send interrupts at a default rate of 100 Hz when they have data to send to the computer. Also, USB mice do not cause the USB controller to interrupt the system when they have no status change to report according to the USB HID specification's default profile for mouse devices. Both PS/2 and USB allow the sample rate to be overridden, with PS/2 supporting a sampling rate of up to 200 Hz and USB supporting a polling rate up to 1 kHz as long as the USB mouse runs at full-speed or higher USB speeds.


Game controllers

Modern game controllers and
joystick A joystick, sometimes called a flight stick, is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. A joystick, also known as the control column, is the principal cont ...
s are often USB HID class devices. Unlike legacy game port devices, USB HID class game devices do not normally require proprietary drivers to function. Nearly all game devices will function using onboard drivers as long as the device is designed around the drivers and the USB HID class specifications.


Other devices

The USB HID class specifications allow for myriad other devices under the USB HID class. Some examples are automobile simulation controllers, exercise machines,
telephony Telephony ( ) is the field of technology involving the development, application, and deployment of telecommunication services for the purpose of electronic transmission of voice, fax, or data, between distant parties. The history of telephony is i ...
devices, thermometers, audio controls and medical instrumentation. Even uninterruptible power supplies and
software protection dongle A software protection dongle (commonly known as a dongle or key) is an electronic copy protection and content protection device. When connected to a computer or other electronics, they unlock software functionality or decode content. The hardware ...
s declare themselves under this class, despite the fact they often have no human interface at all. Any device can be a USB HID class device as long as a designer meets the USB HID class logical specifications. This is not to say that there is no need to ship drivers for these devices, nor that an operating system will immediately recognize the device. This only means that the device can declare itself under the human interface device class.


Security vulnerabilities

The USB interface is vulnerable to security exploits such as
BadUSB BadUSB is a computer security attack using USB devices that are programmed with malicious software. For example, USB flash drives can contain a programmable Intel 8051 microcontroller, which can be reprogrammed, turning a USB flash drive into a ma ...
that abuse the combination of USB's ability to connect many different kinds of devices, its inability to verify that devices are actually what they claim to be, the possibility for USB devices to change their type or announce additional subdevices while plugged in, and its default behavior of accepting any device that connects to it. As a partial countermeasure, PS/2 peripherals may be used instead together with disabling all USB ports.


Drivers

One of the benefits of a well-defined specification like the USB HID class is the abundance of
device driver In computing, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabling operating systems and o ...
s available in most modern operating systems. The USB HID class devices and their basic functions are defined in USB-IF documentation without any specific software in mind. Because of these generic descriptions, it is easy for operating system designers to include functioning drivers for devices such as keyboards, mice, and other generic human interface devices. The inclusion of these generic drivers allows for faster deployment of devices and easier installation by end-users.


Logical specifications


Functional characteristics

The USB human interface device class can be used to describe both device and interface classes. The interface class is used when a USB device can contain more than one function. It is possible, therefore, to have USB devices with two different interfaces at the same time (for example, a USB telephone may use a keypad covered by the HID class and a speaker covered by the USB communications device class). The interface devices are also defined with subclass descriptors. The subclass descriptor is used to declare a device bootable. A boot device meets a minimum adherence to a basic
protocol Protocol may refer to: Sociology and politics * Protocol (politics), a formal agreement between nation states * Protocol (diplomacy), the etiquette of diplomacy and affairs of state * Etiquette, a code of personal behavior Science and technology ...
and will be recognized by a computer's
BIOS In computing, BIOS (, ; Basic Input/Output System, also known as the System BIOS, ROM BIOS, BIOS ROM or PC BIOS) is firmware used to provide runtime services for operating systems and programs and to perform hardware initialization during the b ...
. Each USB HID interface communicates with the host using either a ''control'' pipe or an ''interrupt'' pipe. ''Isochronous'' and ''bulk'' pipes are not used in HID class devices. Both IN and OUT control transfers are required for enumeration; only an IN interrupt transfer is required for HID reports. OUT interrupt transfers are optional in HID-class devices.


Reports

The USB HID class requires that every device describes how it will communicate with the host device in order to accurately predict and define all current and future human interface devices. During enumeration the device describes how its reports are to be structured so that the host device can properly prepare to receive this information. The host periodically polls the device's interrupt IN endpoint during operation. When the device has data to send it forms a report and sends it as a reply to the poll token. Common devices such as keyboards and mice send reports that are compliant with standards set by the USB Implementers Forum (USB-IF). When a vendor makes a custom USB HID class device, the reports formed by the device need to match the report description given during enumeration and the driver installed on the host system. In this way it is possible for the USB HID class to be extremely flexible.


USB HID API

There are two levels of APIs related to USB HID: the USB level and the
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
level. At the USB level, there is a protocol for devices to announce their capabilities and the operating system to parse the data it gets. The operating system then offers a higher-level view to applications, which do not need to include support for individual devices but for classes of devices. This
abstraction layer In computing, an abstraction layer or abstraction level is a way of hiding the working details of a subsystem. Examples of software models that use layers of abstraction include the OSI model for network protocols, OpenGL, and other graphics libr ...
allows a game to work with any USB controller, for example, even ones created after the game.


See also

*
USB On-The-Go USB On-The-Go (USB OTG or just OTG) is a specification first used in late 2001 that allows USB devices, such as tablets or smartphones, to act as a host, allowing other USB devices, such as USB flash drives, digital cameras, mouse or keyboa ...
(OTG)


References


External links


USB.org
the homepage of the USB Implementers Forum, Inc.
USB in a NutshellUSB-IF HID Tools
the USB-IF's page devoted to human interface devices, includes all approved documentation

a collection of articles about, and example code for USB HID devices.
PC System Guides
Microsoft's PC System specifications (e.g. PC '97, PC '98) {{USB USB